package dk.aau.walkietalkieui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import dk.aau.walkietalkieui.fragment.ChatFragment;
import dk.aau.walkietalkieui.fragment.ContactListFragment.IContactListFragment;

public class ContactListActivity extends FragmentActivity 
implements IContactListFragment{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
	
	@Override
	public void onMenuItemSelected(int position) {

		if(findViewById(R.id.ChatFragmentContent) != null) {
			// if the right panel exists, load the content
			FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
			ft.setCustomAnimations(
					R.anim.slide_in_top, R.anim.slide_out_right);
			ft.replace(R.id.ChatFragmentContent,
				ChatFragment.newInstance(position),
				ChatFragment.TAG);
			//ft.addToBackStack(null);
			ft.commit();
		} else {
			Intent i = new Intent(this, ChatActivity.class);
			i.putExtra(ChatActivity.KEY_SELECTED_INDEX,
					position);
			startActivity(i);
		}
		
	}
	
	
}
